/**
 * @param {number[]} nums
 * @return {boolean}
 */
 var containsDuplicate = function(nums) {
  let set = new Set()
  let i = 0
  while(i<nums.length){
    if(!set.has(nums[i])){
      set.add(nums[i++])
    }else {
      return true
    }
  }

  return false
};
console.log(containsDuplicate([1,2,3,4]));